package lxm.spi.spicore;

import lxm.spi.spiinterface.People;

import java.util.Iterator;
import java.util.ServiceLoader;

public class PeopleFactory {
    public void invoker() {
        ServiceLoader<People> services = ServiceLoader.load(People.class);
        Iterator<People> peoples = services.iterator();
        boolean notFound = true;
        while (peoples.hasNext()) {
            notFound = false;
            People people = peoples.next();
            people.people();
        }
        if (notFound) {
            throw new RuntimeException("未发现具体实例");
        }
    }
}
